function Visualization3D(volData, stretch, alphamap, overlap, overlapData,overlapRadius)
%可视化3D光场图像   stretch为拉伸比例

    if (~exist('stretch','var'))
        stretch = [1 1 1];
    end

    if ~exist('alphamap','var') ||  isempty(alphamap)
        alphamap = zeros(1,256); % 初始化
        position = round(256 * 0.05); % 找到5%位置的索引（四舍五入取整）
        alphamap(1,position) = 1; % 在10%位置设置为1
        alphamap(1,1:position) = linspace(0, 1, position); % 线性上升到1
        alphamap(1,position:end) = 1; % 后续保持为1
        alphamap=alphamap';
    end

    if (~exist('overlap','var'))
        overlap = 0;
    end


    if (~exist('overlapData','var'))
        overlapData = [];
    end

    if (~exist('overlapRadius','var'))
        overlapRadius = 1;
    end

    %设置拉伸比例
    sx = stretch(1);
    sy=  stretch(2);
    sz = stretch(3);

    A = [sx 0 0 0; 0 sy 0 0; 0 0 sz 0; 0 0 0 1];
    tformVol = affinetform3d(A);

    % 创建3D查看器
    viewer = viewer3d(BackgroundColor="black",BackgroundGradient="off");



    volshow(volData,Parent=viewer,RenderingStyle="VolumeRendering", ...
        Colormap=[0 1 0],Alphamap=alphamap,Transformation=tformVol);



    if overlap==1

        % 构建与原始体数据相同大小的 label 数据
        labelData = zeros(size(volData), 'uint8'); % 创建全零矩阵
    
        [xSize, ySize, zSize] = size(volData); % 获取体数据大小
    
        cubeRadius = overlapRadius; % 定义立方体半径（半径为1意味着立方体边长为3）
    
         % 提取中心坐标并转换为整数索引
        centroids = round(overlapData);
    
        for i = 1:size(centroids, 1)
            % 获取中心坐标
            xCenter = centroids(i, 1);
            yCenter = centroids(i, 2);
            zCenter = centroids(i, 3);
    
             % 确保中心点在有效范围内
            if xCenter > 0 && xCenter <= ySize && ...
               yCenter > 0 && yCenter <= xSize && ...
               zCenter > 0 && zCenter <= zSize
        
                % 确定立方体区域的范围
                xRange = max(1, xCenter-cubeRadius) : min(ySize, xCenter+cubeRadius);
                yRange = max(1, yCenter-cubeRadius) : min(xSize, yCenter+cubeRadius);
                zRange = max(1, zCenter-cubeRadius) : min(zSize, zCenter+cubeRadius);
        
                % 将立方体区域设置为最大值
                labelData(yRange, xRange, zRange) = 255;
            end
        end
        
        % 显示中心坐标
        volshow(labelData,Parent=viewer,RenderingStyle="VolumeRendering", ...
            Colormap=[1 0 1],Alphamap=linspace(0,1,256),Transformation=tformVol);

    end


end